import os, re, subprocess


class AdbConnect(object):
    def __init__(self):
        pass

    def judge_connect(self):
        adb_cmd = {
            "phone_device": "adb get-serialno",
            "phone_version": "adb shell getprop ro.build.version.release",
            "sdk_version": "adb shell getprop ro.build.version.sdk",
            "phone_model": "adb -d shell getprop ro.product.model",
            "phone_brand": "adb -d shell getprop ro.product.brand",
        }

        device = os.popen("adb get-serialno").readline()
        if len(device) != 0:
            return device
        else:
            print("手机连接有问题，请重新连接.")

    def get_info(self):
        connect = AdbConnect.judge_connect()
        phone_info = {}
        dict = {'Name': 'Zara', 'Age': 7}
        print("Value :{}".format(dict.values()))
        if len(connect) != 0:
            # 获取系统设备系统信息
            sysInfo = subprocess.check_output('adb shell cat /system/build.prop')

            # 获取安卓版本号
            androidVersion = re.findall("version.release=(\d\.\d)*", sysInfo, re.S)[0]

    def wired(self):
        pass

    def wireless(self):
        pass
